<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>



    <script>
        //面向对象写法
        function Anni(name, age) {
            this.name = name;
            this.age = age;
            // this.speak = function () {
            //     console.log("我是" + this.name + "今年" + this.age);
            // }
            // 原型  prototype
            // 通过原型挂载 函数 会更省内存
            Anni.prototype.speak = function(){
                console.log("我是" + this.name + "今年" + this.age);
            }
            //return{
            // name:"xxx",
            // age:age,
            // speak.function () {  
            // }
            // }
        }
        let a = new Anni("张三",22)
        let b = new Anni("李四",24)



        console.log(a,b);
        






    </script>
</body>

</html>